package com.mybatis.dao;

import com.lanhai.model.Agv;
import com.lanhai.utils.DateUtil;

import java.util.Map;

public class AgvSqlProvider {

	public String selectAll(Map<String, Object> map) {
		String sql = "select * from agv";
		return sql;
	}

	public String updateTempData(Agv agv) {
		String updateSql = "update temp_agv set lastPoint=" + agv.getLastPoint() + ",lastJoinStationId="
				+ agv.getLastJoinStationId() + ",lastJoinStationName='" + agv.getLastJoinStationName() + "'"
				+ ",nextDot='" + agv.getNextDot() + "'" + ",startPoint=" + agv.getStartPoint() + ",endPoint="
				+ agv.getEndPoint() + ",isMultiPath=" + agv.getIsMultiPath() + ",pGroup=" + agv.getpGroup() + ",pType="
				+ agv.getpType() + ",parkId=" + agv.getParkId() + ",parkName='" + agv.getParkName() + "'"
				+ ",lockGroup=" + agv.getLineLockGroup() + ",goal=" + agv.getGoal() + ",isStep = " + agv.getIsStep()
				+ ",nextStep = " + agv.getNextStep();
		if (agv.getWaitParkTimes() != null) {
			String ljt = DateUtil.getTimeDate(agv.getWaitParkTimes());
			updateSql += ",waitParkTime='" + ljt + "'";
		}
		updateSql += " where id=" + agv.getId();
		return updateSql;
	}

	public String insertTempData(Agv agv) {
		String sql = "insert into  temp_agv(id,lastPoint,lastJoinStationId,lastJoinStationName,"
				+ "nextDot,startPoint,endPoint,isMultiPath,pGroup,pType,parkId,parkName,lockGroup,goal,nextStep)"
				+ " values (" +  agv.getId() + "," + agv.getLastPoint() + "," + agv.getLastJoinStationId() + ",'"
				+ agv.getLastJoinStationName() + "','" + agv.getNextDot() + "'," + agv.getStartPoint() + ","
				+ agv.getEndPoint() + "," + agv.getIsMultiPath() + "," + agv.getpGroup() + "," + agv.getpType() + ","
				+ agv.getParkId() + ",'" + agv.getParkName() + "'," + agv.getLineLockGroup() + "," + agv.getGoal() + ","
				+ agv.getNextStep() + ")";
		return sql;
	}

	// 添加agv的数据
	public String insertAgvData(Agv agv) {
		String sql = "insert into agv(id,ctrlFlag,ipAddress,port) values (" + agv.getId() + "," + agv.getCtrlFlag()
				+ ",'" + agv.getIpAddress() + "'," + agv.getPort() + ")";
		return sql;
	}

}
